<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./jquery/jquery.mobile-1.4.5.min.css">
<script src="./jquery/jquery.min.js"></script>
<script src="./jquery/jquery.mobile-1.4.5.min.js"></script>

<style type="text/css">
	.ui-content{
		background-color: #FFFFCC;
		color:BLACK;
	}
	#titles{
		//color: #003366;
    //background-color: #99CCCC;
	}
	#doget{
		background-color: #99CCCC;
	}
  #result{
    padding: 10px;
    background-color: #CCFFCC;
  }
  #ttt{
      color: #339933;

  }


</style>

</head>
<body>

<div data-role="page">
  <div data-role="header" id="titles">
  <h3>成绩查询</h3>
  </div>

  <center id="ttt"><h3>MHK汉语考试成绩查询</h3></center>

  <div data-role="main" class="ui-content">
    <form method="post" action="mhk.php">
      <div class="ui-field-contain">

	      <input type="text" name="id" id="id" placeholder="请输入身份证号..">
	     <fieldset data-role="controlgroup">
          <legend>请选择考试级别：</legend>
          <label for="c1">MHK3级</label>
          <input type="radio" name="level" id="c1" value="3">
          <label for="c2">MHK4级</label>
          <input type="radio" name="level" id="c2" value="4"> 
        </fieldset>

      </div>
      <center>
      	 <input id="doget" type="submit" data-inline="true" value="查询">
      </center>
    </form>
  </div>

  <div id="result">
    <?php
      #header("Content-type: text/html; charset=utf8");
      $level = $_POST['level'];
      $id = $_POST['id'];
      $homeDir = __DIR__;
      #echo "准考证号:$id lenvel:$level/id=".strlen($id).":level=".strlen($level);
      if($level=="" && $id=="") echo "";
      else {
          $homeDir = __DIR__;
          $output = shell_exec("python3 $homeDir/py/mhk.py $id $level $homeDir/py/cache/");
          $array = explode(',', $output);
          $array = explode("b'", $output);
          $res = "";
          foreach ($array as $value) {
            $res = $res.urldecode($value);
          }
          $res = explode("'",$res);
          for($i=0;$i<sizeof($res)-1;$i++){
            echo "$res[$i]";
            if($i%2==1) echo "<br>";
            else echo ":";
          }
      }
      
    ?>
  </div>

</div>

</body>
</html>
